<template>
<div class="sou">
<el-autocomplete
  popper-class="my-autocomplete"
  v-model="state3"
  :fetch-suggestions="querySearch"
  placeholder="请输入内容"
  @select="handleSelect">
  <i
    class="el-icon-search el-input__icon"
    slot="suffix"
    @click="handleIconClick">
  </i>
  <template slot-scope="props">
    <div class="name">{{ props.item.value }}</div>
    <span class="addr">{{ props.item.address }}</span>
  </template>
</el-autocomplete>
</div>
</template>
<style>
.my-autocomplete {
  li {
    line-height: normal;
    padding: 7px;

    .name {
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .addr {
      font-size: 12px;
      color: #b4b4b4;
    }

    .highlighted .addr {
      color: #ddd;
    }
  }
}
.sou{
position:absolute;
margin-top:-50px;
margin-left:1300px;
}

</style>

<script>
  export default {
    data() {
      return {
        restaurants: [],
        state3: ''
      };
    },
    methods: {
      querySearch(queryString, cb) {
        var restaurants = this.restaurants;
        var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
        // 调用 callback 返回建议列表的数据
        cb(results);
      },
      createFilter(queryString) {
        return (restaurant) => {
          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
      loadAll() {
        return [
          { "value": "惠普 spectre13 v115tu 超薄笔记本电脑商务游戏超极本", "address": "" },
          { "value": "惠普 spectre13 v115tu 超薄笔记本电脑商务游戏超极本）", "address": "" },
          { "value": "	惠普 envy 13 笔记本i7独显轻薄便携13.3英寸超薄游戏本8代CPU", "address": "" },
       
        ];
      },
      handleSelect(item) {
        console.log(item);
      },
      handleIconClick(ev) {
        console.log(ev);
      }
    },
    mounted() {
      this.restaurants = this.loadAll();
    }
  }
</script>
